#include <iostream>

using namespace std;

using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
using std::setw;
void select( int [], const int, bool (*)( int, int ) );
void swap( int * const, int * const );
bool first( int, int );
bool second( int, int );
int main()
{
  const int arraySize = 10;
  int counter;
  int a[ arraySize ] = { 83, 64, 24, 48, 10, 122, 189, 681, 415, 337 };
  cout << "姓名：郭大帅\n";
  cout << "学号：：010220100164\n";
  cout << "\nData items in original\n";
  for ( counter = 0; counter < arraySize; counter++ )
    cout << setw( 4 ) << a[ counter ];
  select( a, arraySize, second );
  cout << "\nData items in first\n";
  for ( counter = 0; counter < arraySize; counter++ )
    cout << setw( 4 ) << a[ counter ];
  select( a, arraySize, first );
  cout << "\nData items in second\n";
  for ( counter = 0; counter < arraySize; counter++ )
    cout << setw( 4 ) << a[ counter ];
  cout << endl;
  getchar();
  return 0;
}
void select( int work[], const int size, bool (*compare)( int, int ) )
{
  int st;
  for ( int i = 0; i < size - 1; i++ )
  {
    st = i;
    for ( int index = i + 1; index < size; index++ )
      if ( !(*compare)( work[ st ], work[ index ] ) )
        st = index;
    swap( &work[ st ], &work[ i ] );
  }
}
void swap( int * const element1Ptr, int * const element2Ptr )
{
  int hold = *element1Ptr;
  *element1Ptr = *element2Ptr;
  *element2Ptr = hold;
}
bool first( int a, int b )
{
  return a < b;
}
bool second( int a, int b )
{
  return a > b;
}